
/** 表格表头 */
export const tableColumns = (t: (msg:string) => string) => [
  {
    prop: 'id',
    type: 'selection',
    label: t('table.selection'),
    width: 55,
    reserveSelection: true
  },
  {
    prop: 'id',
    label: t('table.id'),
    minWidth: 120,
  },
  {
    prop: 'export_key_name',
    label: t('table.type'),
    minWidth: 120,
  },
  {
    prop: 'file_path',
    label: t('table.path'),
    minWidth: 120,
  },
  {
    prop: 'file_size',
    label: t('table.size'),
    minWidth: 120,
    format: (val:number) => `${val/1000}kb`
  },
  {
    prop: 'export_status_name',
    label: t('table.status'),
    minWidth: 120,
  },
  {
    prop: 'create_time',
    label: t('table.created'),
    minWidth: 120
  },
  {
    prop: 'action',
    label: t('table.operation'),
    width: 130,
    showOverflowTooltip: false,
    fixed: 'right',
  },
];

/** 表格搜索表单 */
export const tableSearchFormItems = (t: (msg:string) => string) => [
  {
    attrs: {
      label: t('search.type'),
      prop: 'export_key',
    },
    value: '',
    component: {
      is: 'el-select',
      props: {
        placeholder: t('search.type.placeholder'),
      },
    },
    childrenComponent: {
      is: 'el-option',
      children: [],
    },
  },
  {
    attrs: {
      label: t('search.status'),
      prop: 'export_status',
    },
    value: '',
    component: {
      is: 'el-select',
      props: {
        placeholder: t('search.status.placeholder'),
      },
    },
    childrenComponent: {
      is: 'el-option',
      children: [],
    },
  },
  {
    attrs: {
      label: t('search.date'),
      prop: 'create_time',
    },
    value: [],
    component: {
      is: 'el-date-picker',
      props: {
        type: "datetimerange",
        startPlaceholder: t('search.date.start.placeholder'),
        endPlaceholder: t('search.date.end.placeholder'),
        defaultTime: [
          new Date(2000, 1, 1, 0, 0, 0),
          new Date(2000, 2, 1, 23, 59, 59),
        ],
        valueFormat: "YYYY-MM-DD HH:mm:ss",
        shortcuts: [
          {
            text: t('search.date.shortcuts0'),
            value: () => {
              const end = new Date(new Date().setHours(23,59,59))
              const start = new Date(new Date().setHours(0,0,0))
              // start.setDate(start.getDate() - 7)
              return [start, end]
            },
          },
          {
            text: t('search.date.shortcuts1'),
            value: () => {
              const end = new Date(new Date().setHours(23,59,59))
              const start = new Date(new Date().setHours(0,0,0))
              start.setDate(start.getDate() - 7)
              return [start, end]
            },
          },
          {
            text: t('search.date.shortcuts2'),
            value: () => {
              const end = new Date(new Date().setHours(23,59,59))
              const start = new Date(new Date().setHours(0,0,0))
              start.setMonth(start.getMonth() - 1)
              return [start, end]
            },
          },
          {
            text: t('search.date.shortcuts3'),
            value: () => {
              const end = new Date(new Date().setHours(23,59,59))
              const start = new Date(new Date().setHours(0,0,0))
              start.setMonth(start.getMonth() - 3)
              return [start, end]
            },
          },
        ]
      },
    },
  },
];
